function compareFunction(a, b) {
    if (a < b) {
        if (a[0] === b[0] && a.includes("北")) {
            return 1;
        }
        return -1;
    } else {
        if (a[0] === b[0] && b.includes("北")) {
            return -1;
        }
        return 1;
    }
}

function sortStringList(arr) {
    const arrayProxy = new Proxy(arr, {
        get: function (target, key, receiver) {
            if ('push' in target && typeof target["push"] === "function") {
                target["push"] = function (...items) {
                    Array.prototype.push.apply(this, items);
                    sortStringList(this);
                    return this.length;
                };
            }
            return Reflect.get(target, key, receiver);
        },
    });

    return arrayProxy.sort(compareFunction);
}

const arr =['B东','A东','A北','D南',"C南",'B南','C东','A南','D东','B西','B北','A西','C西','C北','D西','D北']
sortStringList(arr);
console.log(`arr: ${arr}`); // arr: A东,A南,A西,A北,B东,B南,B西,B北,C东,C南,C西,C北,D东,D南,D西,D北
arr.push('E北','F西','E东');
console.log(`arr: ${arr}`); // arr: A东,A南,A西,A北,B东,B南,B西,B北,C东,C南,C西,C北,D东,D南,D西,D北,E东,E北,F西
